package feature

import (
	"gohub/app/models"
	"gohub/pkg/database"
)

// Feature 模型
type Feature struct {
	models.BaseModel

	Title      string  `json:"title,omitempty"`
	Percentage float64 `json:"percentage,omitempty"`
	Content    string  `json:"content,omitempty"`

	models.CommonTimestampsField
}

// Create 创建，通过 Feature.ID 来判断是否创建成功
func (featureModel *Feature) Create() {
	database.DB.Create(&featureModel)
}

func (featureModel *Feature) Save() (rowsAffected int64) {
	result := database.DB.Save(&featureModel)
	return result.RowsAffected
}

func (Feature) TableName() string {
	return "admin_feature"
}
